package Server;

import java.util.ArrayList;

public class MailBox {

	private ArrayList<String> currentMessage;


	public MailBox() {

		currentMessage = new ArrayList<String>();
	}

	public synchronized String  getMessage() {
		while (currentMessage.isEmpty()) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		String temp = currentMessage.remove(0);
		notifyAll();
		return temp;
	}

	public synchronized void putMessage(String m) {
		currentMessage.add(m);
		notifyAll();
	}

	

}
